package org.xyz.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public final class EulaHelper {
	/**
	 * 判断是否是第一次启动app
	 * 
	 * @param context
	 *            上下文
	 * @return
	 */
	final public static boolean isFristIn(Context context) {
		SharedPreferences sp = context.getSharedPreferences("first_pref",
				Context.MODE_PRIVATE);
		return sp.getBoolean("isFristIn", true);
	}

	/**
	 * 引导完成后改变isFristIn为false
	 * 
	 * @param context
	 *            上下文
	 */
	final public static void setGuided(Context context) {
		SharedPreferences sp = context.getSharedPreferences("first_pref",
				Context.MODE_PRIVATE);
		if (sp != null) {
			Editor mEditor = sp.edit();
			mEditor.putBoolean("isFristIn", false);
			mEditor.commit();
		}
	}

	final public static boolean isVibrator(Context context) {
		SharedPreferences sp = context.getSharedPreferences("Setting_pref",
				Context.MODE_PRIVATE);
		return sp.getBoolean("isVibrator", true);
	}

	final public static void setVibratorFlag(Context context, boolean flag) {
		SharedPreferences sp = context.getSharedPreferences("Setting_pref",
				Context.MODE_PRIVATE);
		if (sp != null) {
			Editor mEditor = sp.edit();
			mEditor.putBoolean("isVibrator", flag);
			mEditor.commit();
		}
	}

	final public static boolean isAudio(Context context) {
		SharedPreferences sp = context.getSharedPreferences("Setting_pref",
				Context.MODE_PRIVATE);
		return sp.getBoolean("isAudio", true);
	}

	final public static void setAudioFlag(Context context, boolean flag) {
		SharedPreferences sp = context.getSharedPreferences("Setting_pref",
				Context.MODE_PRIVATE);
		if (sp != null) {
			Editor mEditor = sp.edit();
			mEditor.putBoolean("isAudio", flag);
			mEditor.commit();
		}
	}
}
